package com.yyc.system.service.impl;

import com.yyc.system.dao.TUserMapper;
import com.yyc.system.model.TUser;
import com.yyc.system.service.ITUserService;

import tk.mybatis.mapper.entity.Condition;

import com.yyc.core.AbstractService;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;


/**
 * Created by yyc on 2018/12/26.
 */
@Service
@Transactional( isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public class TUserServiceImpl extends AbstractService<TUser> implements ITUserService {
    @Autowired
    private TUserMapper tUserMapper;

	@Override
	public TUser login(TUser user) {
		Condition condition = new Condition(TUser.class);
		condition.createCriteria().andEqualTo("userName", user.getUserName()).andEqualTo("password", user.getPassword());
		List<TUser> userList = this.findByCondition(condition);
		if(userList.size()>0){
			return userList.get(0);
		}else{			
			return null;
		}
	}

}
